package com.weipai.springboot.module.mapper;

import com.weipai.springboot.model.PropertyOption;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface PropertyOptionMapper {
    int deleteByPrimaryKey(String optionId);

    int insert(PropertyOption record);

    int insertSelective(PropertyOption record);

    PropertyOption selectByPrimaryKey(String optionId);

    int updateByPrimaryKeySelective(PropertyOption record);

    int updateByPrimaryKey(PropertyOption record);

    //根据属性id查询所有的属性选项
    List<PropertyOption> getOptionByPropertyId(String id);

    //得到数据库中该属性一共有多少个属性选项
    List<Map<String, Object>> getOptionAmountByPropertyId(String id);

    //修改
    @Update("update c_property_option set option_value=#{optionValue}  , option_sort=#{optionSort} where option_id=#{optionId}")
    int updateOptionName(@Param("optionId") String optionId, @Param("optionValue") String optionValue,@Param("optionSort") Integer optionSort);

    //验证此商品的此属性是否有关联
    int verifyIdUse(@Param("goodsId") String goodsId, @Param("optionId") String optionId);

    @Delete("delete from c_property_option where property_id=#{id}")
    void deleteByPropertyId(String id);

    //验证此产品是否关联了此属性
    int verifyIdUseBySpuNumberAndOption(@Param("spuNumber") String spuNumber, @Param("optionId") String optionId);
}